/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.agi.devsol.aplicacao.requisito;

import br.com.agi.devsol.dominio.Requisito;
import br.com.agi.devsol.ejb.requisito.RepositorioRequisito;
import java.io.Serializable;
import javax.ejb.EJB;
import javax.enterprise.context.Conversation;
import javax.enterprise.context.ConversationScoped;
import javax.inject.Inject;
import javax.inject.Named;

/**
 *
 * @author rgrosz
 */
@ConversationScoped
@Named
public class ColetorRequisito implements Serializable{
    private Requisito requisito;
    
    @Inject
    private Conversation conversation;
    
    @EJB
    private RepositorioRequisito repositorio;
    
    public void createRequisito(){
        this.requisito = new Requisito();
    }
    
    public void incluirRequisito(){
        this.repositorio.incluirRequisito(this.requisito);
    }
    
    public void initConversation(){
        if(!conversation.isTransient()){
            conversation.end();
        }
        conversation.begin();
    }
    
    public Requisito getRequisito() {
        return requisito;
    }

    public void setRequisito(Requisito requisito) {
        this.requisito = requisito;
    }
    
    public void setRepositorioRequisito(RepositorioRequisito repositorio){
        this.repositorio = repositorio;
    }
    
    public void setConversation(Conversation conversation){
        this.conversation = conversation;
    }
}
